home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-readerstuff-
/
james_boyd
/
rogobox.asc
< prev
next >
Wrap
Text File
|
2000-03-04
|
31KB
|
1,110 lines
.
.RogoboxInfo
; Rogobox - "RollOver - GOod BOy!" + X :)
; ^ ^ ^^ ^^ ^
; Javascript rollover generator
; (Public Domain program and source code - "DoWhatYouLikeWare"
; --
; Written by James L Boyd - thesurfaces@rockers.co.uk
; -------------------------------------------------------------------------
; Sections listed at right side of screen:
; RogoboxInfo - Basic information about Rogobox
; ToDo - Still to be coded/ideas
; CompileInfo - Information for Blitz programmers
; History - Program history/changes
; LibChecks - Check for required libraries
; Funcs - Reused code in statements and functions
; TopOfCode - Start of main code (& version strings)
; Prefs - Tooltype code
; IMPORTANT - Change when developing/compiling executables
; Variables - Main variables
; MainLoop - Main loop (duh!)
; Gosubs - stuff that went into Gosubs easier (don't ask ;)
; HTMLDemo - the generated HTML code
; -------------------------------------------------------------------------
.
.ToDo ; In no particular order:
; Go all reqtools?
; Optimise for executable size
; Add other Javascript features [ NEW PROGRAM! ]
; -------------------------------------------------------------------------
.
.CompileInfo
; * * * * I M P O R T A N T ! * * * *
; Make sure you comment out the section at the
; .IMPORTANT label before creating an executable!
; Make sure you have Blitzlibs:amigalibs.res set in
; your Compiler Options! This code uses the Blitz
; reqtools includes, as well as some OS structures.
; Newly added reqtools constants. The weird thing is that
; my setup works even with this stuff disabled; some other
; people's setups don't. Yet I don't get any "Duplicated
; constant" kind of errors! Oh, well...
#RT_TagBase =#TAG_USER
#RT_Window =(#RT_TagBase+1)
#RT_ReqPos =(#RT_TagBase+3)
#RT_LockWindow =(#RT_TagBase+13)
#REQPOS_POINTER =0
#RTGL_GadFmt =(#RT_TagBase+34)
#RTGS_GadFmt =#RTGL_GadFmt
#RTGL_TextFmt =(#RT_TagBase+38)
#RTGS_TextFmt =#RTGL_TextFmt
#RTGL_BackFill =(#RT_TagBase+37)
#RTGS_BackFill =#RTGL_BackFill
#RTEZ_Flags =(#RT_TagBase+22)
#RTGL_Flags =#RTEZ_Flags
#RTGS_Flags =#RTGL_Flags
#EZREQB_CENTERTEXT=2
#EZREQF_CENTERTEXT=(1LSL#EZREQB_CENTERTEXT)
#GSREQF_CENTERTEXT=#EZREQF_CENTERTEXT
; You may well run into compile problems with the reqtools
; or datatypes stuff - the datatypes structures are defined
; in a 3rd party reworking of amigalibs.res, which is what
; is used here...
; -------------------------------------------------------------------------
; Doing your own version?
; Feel free to release your own, but please use
; a different name to Rogobox!
; -------------------------------------------------------------------------
.
.History
; Lists Rogobox code changes, plus generated
; HTML/Javascript changes. Last changes at top.
; ---------------------------------------
; Rogobox 1.2
; 23 February 2000
; Program changes:
; ----------------
; Added insertion of image WIDTH & HEIGHT
; attributes via datatypes.
; Because of above, now requires OS3.x. See
; if this can be avoided by skipping datatype
; code...?
; Generated HTML changes:
; -----------------------
; Added WIDTH & HEIGHT attributes.
; ---------------------------------------
; Rogobox 1.1
; 13 February 2000
; Program changes:
; ----------------
; Changed Javascript rollover code (see HTML changes).
; Added reqtools.library check (it's just above .Funcs).
; Removed redundant "invisible text" constant from
; RTGetString function.
; Added reqtools constants used, after Curt Esser
; reported that the include line didn't, er, INCLUDE
; what it was supposed to!
; Changed name to Rogobox - it's now going to be
; a general purpose Javascript gimmick creator :)
; (Future: scrolling text, colour text rollovers, etc.)
; Created Amigaguide documentation.
; Altered About requester to show version.
; Made Load Image/Save HTML paths independent.
; Put Quit and About routines into functions,
; to save executable size and remove duplicated
; code.
; Opens on any public screen.
; Adjusted Quit and New Project requesters to be
; more intelligent (ie whether they pop up or not).
; Added tooltype options:
; AUTONAME - TRUE|FALSE - no prompt for rollover names
; ALT - IMAGE|JS - ALT uses filename or JS name
; PUBSCREEN - [public screen name or ASKME for a list]
; BORDER - [0-xxxx] - image borders
; IMAGESIZES - TRUE|FALSE - get image sizes via datatypes
; DEFAULTLINK - [url] - default image link URL
; PRELOAD - TRUE|FALSE - image preloading code
; IMAGEPATH - [path to picture directory, defaults to RAM:]
; SAVEPATH - [path to save directory, defaults to RAM:]
; NOLINKS - TRUE|FALSE - JS code for null links
; Functions currently working:
; AUTONAME
; ALT
; PUBSCREEN
; BORDER
; IMAGESIZES
; DEFAULTLINK
; PRELOAD
; IMAGEPATH
; SAVEPATH
; NOLINKS
; Generated HTML changes:
; -----------------------
; Bob Akerberg let me know that the old code didn't
; work in IBrowse 2, whereas the replacement code he
; sent me works in all 3 main Amiga browsers, plus
; the "Big Two" PC browsers. It also makes for much
; smaller HTML when using multiple rollovers - thanks,
; Bob!
; Added null link code.
; Added image preloading.
; Adjusted HTML layout slightly.
; Added HTML/Javascript comments.
; ---------------------------------------
; Rogobox 1.0
; 7 February 2000
; Program changes:
; ----------------
; First release version.
; Generated HTML changes:
; -----------------------
; First release code.
; -------------------------------------------------------------------------
.
.LibChecks
; Check for required libraries - placed here cos I'm not sure
; if the functions will be affected if any aren't on the
; system...and I can't be bothered checking :)
; Check if we're on OS3.x for datatype stuff:
e$="exec.library"
*lib.Library=OpenLibrary_(&e$,0)
If *lib
v.w=*lib\lib_Version ; Kickstart version
CloseLibrary_ *lib
EndIf
usedt.b=0 ; Datatype usage flag
If v>38 ; Only if we're on OS3.x
*lib.Library=OpenLibrary_("datatypes.library",39)
If *lib
usedt.b=-1 ; We can use datatypes :)
CloseLibrary_ *lib
Else
error$="WARNING:||You need datatypes.library 39+||You won't be able to use|datatypes to get image info!"
Request "Rogobox",error$,"Oh..."
EndIf
EndIf
; Easy way to add more library checks in future:
nolibs.b=1
Dim LibsToCheck$ (nolibs)
Dim LibVersion.b (nolibs)
LibsToCheck$(1) = "reqtools.library"
LibVersion (1) = 38
; Add more like this:
; LibsToCheck$(x) = "[libraryname.library]"
; LibVersion (x) = version
; Now we can check 'em all in a "oner". We do this by
; attempting to open each one in turn and closing it if
; successful (Blitz opens libraries itself), or making
; note of any that don't open:
For a.b=1 To nolibs
*lib.Library=OpenLibrary_(&LibsToCheck$(a),LibVersion(a))
If *lib
CloseLibrary_ *lib
Else
liberror$+LibsToCheck$(a)+", version "+Str$(LibVersion(a))+".|"
EndIf
Next a
If liberror$ ; List all libraries needed
liberror$=Left$(liberror$,Len(liberror$)-1)
Request "Rogobox","You need the following libraries installed:||"+liberror$,"Abort"
End
EndIf
; -------------------------------------------------------------------------
.
.Funcs
; Functions & Statements
; (...and no, I can't be bothered commenting them!)
; -------------------------------------------------------------------------
Function$ ToolString {icon$,tool$}
If Right$(icon$,5)=".info" Then icon$=Left$(icon$,Len(icon$)-5)
*Icon.DiskObject=GetDiskObject_(&icon$)
If *Icon
a.l=FindToolType_(*Icon\do_ToolTypes,&tool$)
If a
a$=Peek$(a)
Else a$=""
EndIf
FreeDiskObject_ *Icon
Else Function Return ""
EndIf
Function Return a$
End Function
; -------------------------------------------------------------------------
; Busy window:
Function.l LockWindow {win.l}
lock.l=AllocMem_(SizeOf .Requester,1)
If lock
win=Peek.l(Addr Window(win))
InitRequester_(lock)
If Request_(lock,win)
*Exec.Library=Peek.l(4)
If *Exec\lib_Version=>39
Dim tag.TagItem(1)
tag(0)\ti_Tag=#WA_BusyPointer,-1
tag(1)\ti_Tag=#TAG_END
SetWindowPointerA_ win,&tag(0)
EndIf
Else
FreeMem_ lock,SizeOf .Requester
lock=0
EndIf
; note - we'd normally free the "lock"
; memory here, but it's needed by the
; UnLockWindow {} function, which does
; free it!
EndIf
Function Return lock
End Function
; -------------------------------------------------------------------------
; un-busy window:
Statement UnlockWindow{win.l,lock.l}
win=Peek.l(Addr Window(win))
*Exec.Library=Peek.l(4)
If *Exec\lib_Version=>39
Delay_ 5
Dim tag.TagItem(0)
tag(0)\ti_Tag=#TAG_END
SetWindowPointerA_ win,&tag(0)
EndIf
EndRequest_ lock,win
FreeMem_ lock,SizeOf .Requester
End Statement
; -------------------------------------------------------------------------
; Exists () replacement (this doesn't keep file locked!):
Function.l Exist {f$}
lock.l=Lock_(&f$,#ACCESS_READ)
If lock
DEFTYPE .FileInfoBlock fib
If Examine_(lock, fib) <> 0
If fib\fib_DirEntryType < 0
size=Peek.l(&fib\fib_Size) ; file
Else size=-1 ; drawer
EndIf
Else size=-2 ; failed to examine file! rare occurence!
EndIf
UnLock_ lock
Else size=0 ; failed to lock file (doesn't exist basically)...
EndIf
Function Return size
End Function
; -------------------------------------------------------------------------
; Reqtools string requester, replaces Blitz's Enforcer-hitter:
; Reqtools structure needed:
NEWTYPE.rtReqInfo
LeftOffset.w
TopOffset.w
Width.l
ReqTitle$
Flags.l
*DefaultFont.TextFont
WaitPointer.l
LockWindow.l
ShareIDCMP.l
*IntuiMsgFunc.Hook
End NEWTYPE
Function$ RTGetString {title$,body$,deftext$,maxchars.l}
body$=Replace$(body$,"|",Chr$(10))
gadget$="OK|Cancel"
#mx=8
Dim ReqTags.TagItem(#mx)
ReqTags(0)\ti_Tag = #RT_Window, Peek.l(Addr Window(Used Window))
ReqTags(1)\ti_Tag = #RTGS_GadFmt, &gadget$
ReqTags(2)\ti_Tag = #RTGS_TextFmt, &body$
ReqTags(3)\ti_Tag = #RT_ReqPos, #REQPOS_POINTER
ReqTags(4)\ti_Tag = #RT_LockWindow, -1
ReqTags(5)\ti_Tag = #RTGS_BackFill, -1
ReqTags(6)\ti_Tag = #RTGS_Flags, #GSREQF_CENTERTEXT
ReqTags(#mx)\ti_Tag = #TAG_DONE
DEFTYPE.rtReqInfo *reqinfo
If Peek.l(&deftext$-4) > maxchars Then maxchars=Peek.l(&deftext$-4)
res.l=maxchars/4
While Frac(res)<>0
maxchars+1
res=maxchars/4
Wend
*mem=AllocMem_(maxchars,#MEMF_PUBLIC|#MEMF_CLEAR)
If *mem
Poke$ *mem,deftext$
result.l=rtGetStringA_ (*mem,maxchars,&title$,*reqinfo,&ReqTags(0)\ti_Tag)
ret$=Peek$ (*mem)
FreeMem_ *mem,maxchars
If result
Function Return ret$
Else Function Return ""
EndIf
EndIf
End Function
; say "hey, no more rollovers!":
Statement MaxOut {}
lock.l=LockWindow {0}
Request "Rogobox","Only 128 rollovers allowed!","Better save now"
UnlockWindow {0,lock}
End Statement
; -------------------------------------------------------------------------
; Quit request:
Function.b Quit {}
SHARED norolls.b, saved.b
If norolls>saved
lock.l=LockWindow {0}
If Request ("Rogobox","Are you sure you want to quit?","Yes|No") Then UnlockWindow {0,lock}:Function Return -1
UnlockWindow {0,lock}
Else Function Return -1
EndIf
End Function
; -------------------------------------------------------------------------
Statement About {}
SHARED v2$
lock.l=LockWindow {0}
Request "Rogobox",v2$,"OK"
UnlockWindow {0,lock}
End Statement
; -------------------------------------------------------------------------
Function$ ProgsName{}
If FromCLI
*stringbuffer = AllocMem_(255, 0)
suc.l=GetProgramName_(*stringbuffer,255)
If suc
pname$=Peek$(*stringbuffer)
EndIf
FreeMem_ *stringbuffer,255
Else pname$=Peek$(Peek.l(FindTask_(0)+$B0)+4)
EndIf
If pname$="" Then pname$="I only work when compiled!"
Function Return pname$
End Function
; -------------------------------------------------------------------------
Function$ StripQuotes {a$}
If Left$(a$,1)=Chr$(34) AND Right$(a$,1)=Chr$(34)
a$=Mid$(a$,2,Len(a$)-2) ; strip "" from string
EndIf
Function Return a$
End Function
; -------------------------------------------------------------------------
Function.s StripFile{p$}
*fileptr.l = FilePart_(&p$)
f$=Peek$(*fileptr)
Function Return f$
End Function
; -------------------------------------------------------------------------
.
.TopOfCode
WBStartup ; run from an icon
NoCli ; no Blitz CLI
; Version string:
v1$="$VER: Rogobox 1.2 (23/02/2000) by James L Boyd "
; Used in About requester:
v2$="Rogobox 1.2 (23/02/2000).|Javascript rollover generator.||Public domain software by James L Boyd."
; -------------------------------------------------------------------------
.
.Prefs
rogobo$=ProgsName{}
; -------------------------------------------------------------------------
.
.IMPORTANT
; ENABLE THIS SECTION (following three lines) WHEN DEVELOPING;
;If rogobo$="I only work when compiled!"
; rogobo$="SYS:Utilities/Rogobox" ; **** change to suit ****
;EndIf
; **********************IMPORTANT********************************
; **** DISABLE above three lines when creating executable!!! ****
; ***************************************************************
; -------------------------------------------------------------------------
; Some defaults for tooltype options:
DEFTYPE.b autoname, altname, nolinks, border, imagesizes, preload
; All set to 0 until tooltypes are read:
; autoname - no prompt for rollover names
; altname - ALT attribute uses filename or rollover name
; nolinks - no links in images - overrides defaultlink$
; border - image border size
; imagesizes - use datatypes to get image dimensions
; preload - use image preloading code in Javascript
; -------------------------------------------------------------------------
; Get tooltype prefs:
defaultlink$ =ToolString {rogobo$,"DEFAULTLINK"}
If ToolString {rogobo$,"AUTONAME"} ="TRUE" Then autoname=-1
If ToolString {rogobo$,"ALT"} ="IMAGE" Then altname =-1
If ToolString {rogobo$,"NOLINKS"} ="TRUE" Then nolinks=-1:defaultlink$=Chr$(34)+"javascript:void(0)"+Chr$(34)
If ToolString {rogobo$,"PRELOAD"} ="TRUE" Then preload=-1
If ToolString {rogobo$,"IMAGESIZES"} ="TRUE"
If usedt Then imagesizes=-1
EndIf
border=Val(ToolString {rogobo$,"BORDER"})
If border <0 Then border=0
imagepath$ =StripQuotes{ToolString {rogobo$,"IMAGEPATH"}}
If Exist {imagepath$}=0 Then imagepath$="RAM:"
savepath$ =StripQuotes{ToolString {rogobo$,"SAVEPATH"}}
If Exist {savepath$}=0 Then savepath$="RAM:"
pubscreen$ =StripQuotes{ToolString {rogobo$,"PUBSCREEN"}}
; -------------------------------------------------------------------------
; tooltype checker:
; a$="autoname="+Str$(autoname)
; a$+"|altname="+Str$(altname)
; a$+"|nolinks="+Str$(nolinks)
; a$+"|imagesize="+Str$(imagesize)
; a$+"|border="+Str$(border)
; a$+"|defaultlink="+defaultlink$
; a$+"|pubscreen="+pubscreen$
; Request "",a$,"OK"
; End
; -------------------------------------------------------------------------
; Find screen:
If pubscreen$<>"ASKME" Then ask.b=0 Else ask=-1
If pubscreen$="" Then pubscreen$="Workbench"
Pubscreens ; If screen isn't found,
; we come back here
; See if public screen exists:
noscreen.b=0 ; Used if screen not found
Dim scr$(127) ; To be on the safe side ;)
*scrs.List=LockPubScreenList_ ()
*mynode.Node=*scrs\lh_Head
count.w=0
While *mynode\ln_Succ
count+1
scr$(count)=Peek$(*mynode\ln_Name)
If scr$(count)=pubscreen$ Then Goto skipscreens
*mynode=*mynode\ln_Succ
Wend
pubscreen$="Workbench" ; Used if not in list
noscreen=-1
skipscreens
UnlockPubScreenList_
; -------------------------------------------------------------------------
; Pubscreen list:
For a=1 To count:sc$+Str$(a)+": "+scr$(a)+"|":Next a
sc$=Left$(sc$,Len(sc$)-1) ; strip last "|"
; -------------------------------------------------------------------------
If noscreen
If count=1
req$=scr$(1)+"|Abort" ; only one screen open
Else For a=1 To count:req$+Str$(a)+"|":Next a:req$+"Abort"
EndIf
If ask=0
info$="The screen you requested wasn't found.||Existing public screens:||"+sc$
Else info$="Choose a screen to open on:||"+sc$
; This appears if the user has PUBSCREEN="ASKME"
EndIf
a=Request ("Rogobox",info$,req$)
If a
pubscreen$=scr$(a)
Goto Pubscreens
Else End
EndIf
EndIf
; Crunch time - open on screen or quit:
*grabscreen.Screen=LockPubScreen_ (&pubscreen$)
If *grabscreen
*scr.Screen=*grabscreen ; not 100% sure if UnlockPubScreen keeps the pointer...I think it does, but... ;)
title$=Peek$(*grabscreen\Title)
FindScreen 0,title$ ; get public screen
UnlockPubScreen_ 0,*grabscreen
Else Request "Rogobox","Can't lock ANY public screen!","Abort"
End
EndIf
; -------------------------------------------------------------------------
; Screen info/font sensitivity:
ScreenToFront_ *scr
sw.w=*scr\Width ; screen width
sh.w=*scr\Height ; screen height
bh.b=*scr\BarHeight+1 ; title bar height
lb.b=*scr\WBorLeft ; window left border
rb.b=*scr\WBorRight ; window right border
*scfont.TextAttr=*scr.Screen\Font ; screen's font
fheight.b=(*scfont.TextAttr\ta_YSize) ; font height
fname$=Peek$(*scfont.TextAttr\ta_Name) ; font name
LoadFont f,fname$,fheight ; use screen's font
gw.w=300 ; width of gadgets
pad.b=3 ; gadget text padding (above & below text)
gh.b=bh+pad ; gadget height (= title bar + padding)
GTButton 0,0,-lb,-bh,gw,gh,"Create new rollover",0 ; first button
GTButton 0,1,-lb,pad,gw,gh,"Save rollover HTML",0 ; second button
GTButton 0,2,-lb,bh+pad*2,gw/2,gh,"About",0 ; third button
GTButton 0,3,(gw/2-lb),bh+pad*2,gw/2,gh,"Quit",0 ; fourth button
; ^^^ "Trial and error does it every time" ;)
numgadshi.b=3 ; number of rows of gadgets the following
; lines will magically adjust the window's
; height to fit :)
ww.w=gw+lb+rb ; calculate window width
wh.w=(gh)*(numgadshi+1)-(pad-2) ; calculate window height
wx.w=(sw/2)-(ww/2) ; centre window x position
wy.w=(sh/2)-(wh/2) ; centre window y position
; -------------------------------------------------------------------------
; Gadtools menus space themselves out properly!
; You need the Ultimate Blitz Basic CD for the GTMenu library;
; to use normal Blitz menus, just remove the "GT" from the
; start of the following commands (plus GTSetMenu beneath
; the Window command).
GTMenuTitle 0,0,"Project"
GTMenuItem 0,0,0,0,"New Project","N"
GTMenuItem 0,0,0,1,"About Rogobox...","A"
GTMenuItem 0,0,0,2,"Quit Rogobox...","Q"
GTMenuTitle 0,1,"Rollovers"
GTMenuItem 0,0,1,0,"Create new...","C"
GTMenuItem 0,0,1,1,"Save HTML...","S"
; -------------------------------------------------------------------------
; Open window:
; Some versions of Blitz don't allow the "window open" check,
; so just uncomment the next line if this applies to you,
; and comment out the following four lines:
; Window 0,wx,wy,ww,wh,$20140e,"Rogobox",1,2
If Window (0,wx,wy,ww,wh,$20140e,"Rogobox",1,2)=0
Request "Rogobox","Rogobox couldn't open its window!","Abort"
End
EndIf
AttachGTList 0,0 ; attach gadgets
GTSetMenu 0 ; attach gadtools menus
; -------------------------------------------------------------------------
.
.Variables
; Main variables:
#maxrolls=127 ; max number of rollovers (keep in a byte ;)
; newbies beware! if you increase this number,
; you need to know what you're doing with bytes,
; words, etc in the rest of the program!
NEWTYPE.Rollover ; custom newtype to hold rollover data
firstpicx.w ; - picture 1 width
firstpicy.w ; - picture 1 height
secndpicx.w ; - picture 2 width
secndpicy.w ; - picture 2 height
name$ ; - rollover name
firstpic$ ; - main image
secndpic$ ; - alternative image
End NEWTYPE
Dim rolls.Rollover (#maxrolls) ; array of rollover buttons
norolls.b=0 ; current rollover number
MaxLen pl$=192 ; setup LOAD ASL file requester path string
MaxLen fl$=192 ; setup LOAD ASL file requester filename string
MaxLen ps$=192 ; setup SAVE ASL file requester path string
MaxLen fs$=192 ; setup SAVE ASL file requester filename string
pl$=imagepath$ :fl$="" ; start image path/file
ps$=savepath$ :fs$="" ; save HTML path/file
; -------------------------------------------------------------------------
.
.MainLoop
; Main loop:
Repeat
Select WaitEvent
Case $100 ; Menu hit
Select MenuHit
Case $0 ; Project menu
Select ItemHit
Case $0 ; New Project
If norolls>0 ; Current rollovers saved?
lock.l=LockWindow {0}
If Request ("Rogobox","New Project||You will lose all existing rollovers!|Are you sure?","Yes|No")
norolls=0 ; easy :)
WTitle "Rogobox"
EndIf
UnlockWindow {0,lock}
Else norolls=0:WTitle "Rogobox"
EndIf
Case $1 ; About
About {}
Case $2 ; Quit
If Quit{} Then End
End Select
Case $1 ; Rollovers menu
Select ItemHit
Case $0 ; Create
Gosub _Create ; GOSUBs?!! Are you the Devil-Child?!!
Case $1 ; Save
Gosub _Save
End Select
End Select
Case $200 ; close gadget hit...quit
If Quit{} Then End
; -------------------------------------------------------------------------
Case $40 ; gadget hit
Select GadgetHit ; but which one? do-de-do-do (Twilight Zone)
Case $0 ; create new rollover
Gosub _Create
Case $1 ; save sample HTML file with rollovers
Gosub _Save
Case $2
About {}
Case $3
If Quit{} Then End
End Select
End Select
; -------------------------------------------------------------------------
Forever
; -------------------------------------------------------------------------
.
.Gosubs
; Those GOSUBs in their true horror! look away! look away!
; -------------------------------------------------------------------------
._Create
If norolls-1=127 Then MaxOut {}:Goto skiproll ; GOTO?!! AAAHH!! It is the Chosen One!!!
; ^^ "semi-hacky" way of keeping my byte :)
; basically, rollover limit reached...
fl$="" ; reset filename each time
; get rollover name:
rname$="Button"+Str$(norolls+1)
If autoname=0
lock.l=LockWindow {0}
rname$=RTGetString {"Rogobox","Enter a name for this rollover:",rname$,30}
UnlockWindow {0,lock}
EndIf
If rname$="" Then Goto skiproll
For a=0 To norolls-1
If rolls (norolls-1)\name=rname$
Request "Rogobox","That name is already in use!|Please choose another","OK"
Pop For:Goto _Create
EndIf
Next a
rolls (norolls)\name=rname$ ; rollover name
; get first picture:
lock.l=LockWindow {0}
a$=ASLFileRequest$ ("Select main image:",pl$,fl$,"(#?.gif|#?.jp#?g|#?.png)")
UnlockWindow {0,lock}
If a$="" OR fl$="" Then Goto skiproll
; Get the image sizes; note that we only need the
; size of the first image, since that's all that
; gets inserted in the code!
If imagesizes
WTitle "Finding image sizes..."
Dim tags.TagItem(2)
tags(0)\ti_Tag = #DTA_SourceType, #DTST_FILE
tags(1)\ti_Tag = #DTA_GroupID, &GID_PICTURE$
tags(2)\ti_Tag = #TAG_DONE
DEFTYPE.DataType *d
DEFTYPE.BitMapHeader *b
*o.b=NewDTObjectA_(&a$,tags(0))
If *o
If GetAttr_ (#PDTA_BitMapHeader,*o,&*b)
rolls (norolls)\firstpicx = Peek.w(&*b\bmh_Width)
rolls (norolls)\firstpicy = Peek.w(&*b\bmh_Height)
EndIf
DisposeDTObject_ *o
EndIf
WTitle "Rogobox ["+Str$(norolls+1)+" created]","Rogobox"
EndIf
a$="file://localhost/"+a$ ; add local file crap
rolls (norolls)\firstpic=a$ ; main image name
; get second picture:
lock.l=LockWindow {0}
a$=ASLFileRequest$ ("Select alternative image:",pl$,fl$,"(#?.gif|#?.jp#?g|#?.png)")
UnlockWindow {0,lock}
If a$="" OR fl$="" Then Goto skiproll
a$="file://localhost/"+a$ ; add local file crap
rolls (norolls)\secndpic=a$ ; alternative image name
; update window title:
WTitle "Rogobox ["+Str$(norolls+1)+" created]","Rogobox"
; "Next!":
norolls+1
skiproll ; something was cancelled; keep norolls...
Return
; -------------------------------------------------------------------------
._Save
If norolls=0
lock.l=LockWindow {0}
Request "Rogobox","You haven't created any rollovers!","Oh yeah..."
UnlockWindow {0,lock}
Goto skipsave
EndIf
overwriteloop ; back here in case of existing file
f$="" ; let's not overwrite any image files :)
lock.l=LockWindow {0} ; lock main window
a$=ASLFileRequest$ ("Save HTML file as:",ps$,fs$,"#?")
UnlockWindow {0,lock} ; unlock main window
If a$="" OR fs$="" Then Goto skipsave
If Exist {a$}
lock.l=LockWindow {0}
If Request ("Rogobox","Overwrite existing file?","Yes|No")=0 Then UnlockWindow {0,lock}:Goto overwriteloop
UnlockWindow {0,lock}
EndIf
If WriteFile (0,a$) ; let's output! rock 'n' roll! etc!
lock.l=LockWindow {0} ; lock main window
FileOutput 0 ; write to file 0
; HTML demo code:
; -------------------------------------------------------------------------
.
.HTMLDemo
; Beginning of HTML file:
NPrint ""
NPrint "<!DOCTYPE HTML PUBLIC "+Chr$(34)+"-//W3C//DTD HTML 3.2//EN"+Chr$(34)+">"
NPrint ""
NPrint "<HTML>"
NPrint ""
NPrint " <HEAD>"
NPrint ""
Print " <META HTTP-EQUIV="+Chr$(34)+"Content-Type"+Chr$(34)+" CONTENT="+Chr$(34); --> continued next line...
NPrint "text/html;CHARSET=iso-8859-1"+Chr$(34)+">"
Print " <META HTTP-EQUIV="+Chr$(34)+"Generator"+Chr$(34)+" CONTENT="+Chr$(34); --> continued next line...
NPrint "Rogobox on AMiGA!"+Chr$(34)+">"
NPrint ""
NPrint " <SCRIPT LANGUAGE="+Chr$(34)+"Javascript"+Chr$(34)+">"
NPrint ""
NPrint " <!-- // Hides code from non-Javascript browsers"
NPrint ""
If preload ; Add image preloading code
NPrint " if (document.images) // Preloads images"
NPrint " {"
EndIf
; -------------------------------------------------------------------------
; list of images to use:
For a=0 To norolls-1
a$=rolls(a)\name
NPrint " var "+a$+"up = new Image(); "+a$+"up.src = "+Chr$(34)+rolls(a)\firstpic+Chr$(34)+";"
NPrint " var "+a$+"dn = new Image(); "+a$+"dn.src = "+Chr$(34)+rolls(a)\secndpic+Chr$(34)+";"
If a<norolls-1 Then NPrint ""
Next a
If preload Then NPrint " }"
; -------------------------------------------------------------------------
; mouseOut (main image - button up):
NPrint ""
NPrint " function MyMouseOutRoutine(ButtonName)"
NPrint " {"
NPrint " if (document.images)"
NPrint " document[ButtonName].src = eval(ButtonName + 'up.src');"
NPrint " }"
; -------------------------------------------------------------------------
; mouseOver (alternative image - button down):
NPrint ""
NPrint " function MyMouseOverRoutine(ButtonName)"
NPrint " {"
NPrint " if (document.images)"
NPrint " document[ButtonName].src = eval(ButtonName + 'dn.src');"
NPrint " }"
; -------------------------------------------------------------------------
; rest of <HEAD> section:
NPrint ""
NPrint " // Allow non-Javascript browsers to continue -->"
NPrint ""
NPrint " </SCRIPT>"
NPrint ""
NPrint " <TITLE>"
NPrint " Javascript rollover example page..."
NPrint " </TITLE>"
NPrint ""
NPrint " </HEAD>"
NPrint ""
; -------------------------------------------------------------------------
; <BODY> section:
NPrint " <BODY BGCOLOR="+Chr$(34)+"#FFFFFF"+Chr$(34)+" TEXT="+Chr$(34)+"#000000"+Chr$(34)+">"
NPrint ""
NPrint " <CENTER>"
NPrint ""
; column of rollovers:
For a=0 To norolls-1
a$=StripFile{rolls(a)\name}
If altname
alt$=StripFile{rolls(a)\firstpic}
Else alt$=rolls(a)\name
EndIf
NPrint " <!--"+a$+" rollover-->"
NPrint " <A HREF="+defaultlink$
NPrint " onClick="+Chr$(34)+"return false;"+Chr$(34)
NPrint " onMouseOver="+Chr$(34)+"MyMouseOverRoutine('"+a$+"')"+Chr$(34)
NPrint " onMouseOut="+Chr$(34)+"MyMouseOutRoutine('"+a$+"')"+Chr$(34)+">"
NPrint " <IMG SRC="+Chr$(34)+rolls(a)\firstpic+Chr$(34)
Print " BORDER="+Chr$(34)+Str$(border)+Chr$(34)+" ALT="+Chr$(34)+alt$+Chr$(34)
Print " NAME="+Chr$(34)+a$+Chr$(34)
If imagesizes
Print " WIDTH="+Chr$(34)+Str$(rolls(a)\firstpicx)+Chr$(34)
Print " HEIGHT="+Chr$(34)+Str$(rolls(a)\firstpicy)+Chr$(34)
EndIf
NPrint ">"
NPrint " </A><BR>"
NPrint ""
Next a
; -------------------------------------------------------------------------
; end of HTML file:
NPrint " </CENTER>"
NPrint ""
NPrint " </BODY>"
NPrint ""
NPrint "</HTML>"
; -------------------------------------------------------------------------
DefaultOutput:CloseFile 0
UnlockWindow {0,lock} ; unlock main window
saved=norolls ; number saved
EndIf
skipsave
Return